﻿namespace WCBG.ToolsForUnity.Tools
{
    using System;
    using UnityEngine;

    public class FUGUITool
    {
        public static Vector3 ScreenPointToUGUIPoint(Canvas canvas, Vector2 screenPosition)
        {
            Vector3 vector = canvas.worldCamera.ScreenToWorldPoint(screenPosition);
            return new Vector3(vector.x, vector.y, canvas.GetComponent<RectTransform>().anchoredPosition3D.z);
        }

        public static Vector3 WorldPointToUGUIPoint(Canvas canvas, Vector3 worldPosition)
        {
            Vector3 vector = Camera.main.WorldToScreenPoint(worldPosition);
            Vector3 vector2 = canvas.worldCamera.ScreenToWorldPoint(vector);
            return new Vector3(vector2.x, vector2.y, canvas.GetComponent<RectTransform>().anchoredPosition3D.z);
        }
    }
}

